﻿#--------------------------------------------------------------------------------------------------------------------------------------------------------
#
# Mi-DevEnv			:	http://midevenv.codeplex.com 
#					:	(c) IT Bridge 2012
#					:	A concept originated by Chris Nurse
#
# Licence			:	GNU General Public License version 2 (GPLv2)
#					:	http://midevenv.codeplex.com/license
#
# Summary           :   This script deploys MDE modules to the PowerShell modules folder
#
#--------------------------------------------------------------------------------------------------------------------------------------------------------

# This is where we want to deploy Mi-DevEnv modules so they can be easily imported
$psModulePath = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules"

cls
Write-Host "Mi-DevEnv : Install modules"
Write-Host "The default powershell module folder is $psModulePath"
Write-Host 
Write-Host "REMINDER: Ensure the appropriate variables in MDE-Common have been configured before deployment" -ForegroundColor Cyan
Write-Host 

# Here is where the deployment command is right now
$executionPath = Split-Path $script:MyInvocation.MyCommand.Path -Parent

# Assume that the parent folder holds the entire script folder structure
$sourcePath = Split-Path $executionPath -Parent

$modules= @("MDE-Host","MDE-Common")

foreach($module in $modules) {

    Write-Host "Deploying $module to $psModulePath"

    if (!(Test-Path C:\Windows\System32\WindowsPowerShell\v1.0\Modules\$module)) {
        New-Item -ItemType Directory -Path $psModulePath\$module | Out-Null
        }

    Copy-Item $executionPath\..\$module\*.* $psModulePath\$module -Force
    }

Write-Host "Done"